package com.cy.store.test;

import com.cy.store.entity.User;
import com.cy.store.mapper.UserMapper;
import com.cy.store.service.IUserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;

@SpringBootTest//表示这是一个springboot测试类，不会随着应用打包
@RunWith(SpringRunner.class)//启动这个单元测试类
public class mappertest {
    @Autowired(required = false)
    private UserMapper userMapper;

    @Autowired
    private IUserService userService;

    @Test
    public void testinsert() {
        User user = new User();
        user.setUsername("aaa");
        user.setPassword("123");
        int i = userMapper.insertUser(user);
        System.out.println(i);
    }

    @Test
    public void testselextByName() {
        User asd = userMapper.findByUsername("asd");
        System.out.println(asd);
    }

    @Test
    public void testupdate() {
        Date date = new Date();
        Integer integer = userMapper.updatePasswordByUid(1, "aaa", "aaa", date);
        System.out.println(integer);
    }

    @Test
    public void updateInfoByUid() {
        User user = new User();
        user.setUid(1);
        user.setPhone("12345600");
        user.setEmail("1144515646@qq.com");
        user.setGender(1);

        Integer integer = userMapper.updateInfoUid(user);
        System.out.println(integer);
    }

    @Test
    public void updateAvatar(){
        Integer g = userMapper.updateAvatarByUid(1, "/upload/avatar.pgn", "管理员", new Date());
        System.out.println(g);
    }

}
